﻿using System.Security.Cryptography;

namespace RemoteSensingImageDirectServer.Untils.Extensions
{
    public static class StringExtensions
    {
        /// <summary>
        /// 获取字符串的md5值
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string ToMD5String(this string str) {
            MD5 md5 = MD5.Create();
            byte[] data = System.Text.Encoding.UTF8.GetBytes(str);
            byte[] md5Data = md5.ComputeHash(data, 0, data.Length);
            return md5Data.Aggregate(string.Empty, (res, b) => res = res + b.ToString("X2"));
        }
    }
}
